package com.ceba.test.modules.email.logicService;

import java.util.Map;

import com.ceba.test.modules.email.entity.EmailEntity;
import org.apache.commons.collections.MapUtils;


public class TemplateContentEmail extends HtmlFileEmail{
	private Map<String, String> templateMap;
	public TemplateContentEmail(EmailEntity emailEntity,Map<String, String> templateMap) {
		super(emailEntity);
		this.templateMap=templateMap;
	}
	
	
	@Override
	public String content() {
		EmailEntity emailEntity=super.getEmailEntity();
		String content=emailEntity.getContent();
		if(MapUtils.isNotEmpty(templateMap)){
			for(String key:templateMap.keySet()){
				String value=templateMap.get(key);
				content=content.replace(key, value);
			}
		}
		emailEntity.setContent(content);
		return super.content();
	}
	
	
	
	public Map<String, String> getTemplateMap() {
		return templateMap;
	}
	public void setTemplateMap(Map<String, String> templateMap) {
		this.templateMap = templateMap;
	}
}
